#pragma once

#include <SharedRep.h>
#include <filesystem/String.hpp>
#include <lib3d/hard/Hardware.h>
#include <lib3d/hard/Manager.h>
#include <HardwareDependentObject.h>
#include <CompilerFeatures.h>
#include <font/AbstractFont.h>

namespace liba {
namespace font {
class FontVisitor;
} // namespace font
namespace lib3d {
namespace node {
namespace text {

struct AtlasMetricsHolder;

class SymbolAtlasRep
	: public liba::HardwareDependentObject<hard::Manager, hard::Texture >
{
public:
	SymbolAtlasRep(const filesystem::String& name);
	~SymbolAtlasRep();

	void render_to_list( hard::Hardware * hardware, hard::RenderTexture * render_texture );
	const AtlasMetricsHolder& GetAtlasMetrics() const;
	int GetWidth() const;
	int GetHeight() const;
protected:
	virtual void on_add_hardware(hard::Manager::hardware_type* ha) LIBA_OVERRIDE;
private:
	std::auto_ptr<hard::Texture> createTexture(hard::Manager::hardware_type* ha);
	std::auto_ptr<struct SymbolAtlasRepPrivates> privates;
};

class SymbolAtlas
	: public Shared<filesystem::String, SymbolAtlasRep>
	, public font::AbstractFont
{
public:
	SymbolAtlas(const filesystem::String& name);
	void render_to_list(hard::Hardware* hardware, hard::RenderTexture* render_texture);
	const AtlasMetricsHolder& GetAtlasMetrics() const { return get_rep()->GetAtlasMetrics(); }
	int GetWidth() const { return get_rep()->GetWidth(); }
	int GetHeight() const { return get_rep()->GetHeight(); }
public: // font::AbstractFont
	virtual void Accept(font::FontVisitor* visitor) LIBA_OVERRIDE;
	virtual font::AbstractFont* clone() LIBA_OVERRIDE;
};


} // namespace text
} // namespace node
} // namespace lib3d
} // namespace liba